package com.viewpagertext.DBHelper.Dao;

/**
 * @author ironjam
 * @version 1.0
 * @project AndroidMusic-master
 * @description
 * @date 2024/5/23 17:07:01
 */


import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.viewpagertext.Model.SearchHistory;

import java.util.List;

@Dao
public interface SearchHistoryDao {

    @Query("SELECT * FROM SearchHistory")
    List<SearchHistory> getAll();

    @Query("SELECT * FROM SearchHistory WHERE id IN (:userIds)")
    List<SearchHistory> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM SearchHistory WHERE name = :first ")
    SearchHistory findByName(String first);

    @Query("insert into SearchHistory(name) values(:first) ")
    void insertByName(String first);
    @Query("SELECT * FROM SearchHistory WHERE name LIKE :last LIMIT 1")
    SearchHistory findByLastName(String last);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(SearchHistory... users);

    @Delete
    void delete(SearchHistory user);
    @Query("delete from SearchHistory ")
    void deleteAll();
}
